﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="CadastrarCurso.aspx.cs" Inherits="RepositorioDeMonografia.CadastrarCurso" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <fieldset class="CadastraCurso">
        <legend>Cadastrar Curso</legend>
        <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" CellPadding="4"
            DataKeyNames="Id" DataSourceID="SqlDataSourceCurso" ForeColor="#333333" GridLines="None"
            Height="50px" Width="529px" DefaultMode="Insert">
            <Fields>
                <asp:TemplateField HeaderText="Nome" SortExpression="Nome">
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Height="20px" Text='<%# Bind("Nome") %>'
                            Width="270px"></asp:TextBox>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <asp:Button ID="Button1" runat="server" CausesValidation="True" CommandName="Insert"
                            Text="Cadastrar" />
                        &nbsp;&nbsp;
                        <asp:Button ID="Button2" runat="server" CausesValidation="False" CommandName="Cancel"
                            Text="Limpar" />
                    </InsertItemTemplate>
                </asp:TemplateField>
            </Fields>
        </asp:DetailsView>
        <asp:SqlDataSource ID="SqlDataSourceCurso" runat="server" ConflictDetection="CompareAllValues"
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM [Curso] WHERE [Id] = @original_Id AND (([Nome] = @original_Nome) OR ([Nome] IS NULL AND @original_Nome IS NULL))"
            InsertCommand="INSERT INTO [Curso] ([Nome]) VALUES (@Nome)" OldValuesParameterFormatString="original_{0}"
            SelectCommand="SELECT [Nome], [Id] FROM [Curso]" UpdateCommand="UPDATE [Curso] SET [Nome] = @Nome WHERE [Id] = @original_Id AND (([Nome] = @original_Nome) OR ([Nome] IS NULL AND @original_Nome IS NULL))">
            <DeleteParameters>
                <asp:Parameter Name="original_Id" Type="Int32" />
                <asp:Parameter Name="original_Nome" Type="String" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="Nome" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="Nome" Type="String" />
                <asp:Parameter Name="original_Id" Type="Int32" />
                <asp:Parameter Name="original_Nome" Type="String" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <br />
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
            AutoGenerateColumns="False" CellPadding="2" CellSpacing="3" DataKeyNames="Id"
            DataSourceID="SqlDataSourceCurso" ForeColor="#333333" GridLines="None" 
            PageSize="4" Width="217px">
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <Columns>
                <asp:BoundField DataField="Nome" HeaderText="Nome" SortExpression="Nome" />
                <asp:CommandField ButtonType="Image" 
                    DeleteImageUrl="~/Imagens/pencil_delete.png" EditImageUrl="~/Imagens/pencil.png"
                    ShowDeleteButton="True" ShowEditButton="True" 
                    CancelImageUrl="~/Imagens/cancel.png" />
            </Columns>
        </asp:GridView>
</asp:Content>
